﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 中文转拼音
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                #region ==拼音==
                string source = this.textBox1.Text.Trim();
                if (source != "")
                {
                    string target = Pinyin.GetPinyin(source);
                    this.textBox2.Text = target;
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }

        private void button2_Click(object sender, EventArgs e)
        {
            try
            {
                #region ==拼音首字母==
                string source = this.textBox1.Text.Trim();
                if (source != "")
                {
                    string target = Pinyin.GetInitials(source);
                    this.textBox2.Text = target;
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);

            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            try
            {
                #region ==拼音第一个字母大写==
                string source = this.textBox1.Text.Trim();
                if (source != "")
                {
                    string target = Pinyin.GetFirstUpper(source);
                    this.textBox2.Text = target;
                }
                #endregion
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }
}
